package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-06-25
 * Time: 16:42
 */
class Student{
    //普通成员变量
    public String name;
    public int age;
    public static String classes = "2022班";
   //构造方法
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("构造方法执行了");
    }

    //实例代码块
    {
        this.name = "122";
        this.age = 120;
        System.out.println("实例代码块执行了");
    }

    //静态代码块
    static{
        classes = "2023";
        System.out.println("静态代码块执行了");
    }
    //成员方法
    public void print(){
        System.out.println(this.name+" "+this.age);
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student("csdn",12);
        student.print();
        System.out.println("===========================");
        Student student1 = new Student("133",21);
        student1.print();


    }
}
